#region Using directives
using System;
using Microsoft.Xna.Framework.Input;
#endregion

namespace SharpWind.Input
{
	internal class InputControl
	{
		#region Fields

		private InputType type = InputType.Analogue;

		private InputSource source = InputSource.None;

		private Keys keys = Keys.None;

		private GamePadInput gamePad = GamePadInput.None;

		private MouseInput mouse = MouseInput.None;

		#endregion

		#region Constructors

		public InputControl( InputType type, InputSource source )
		{
			this.type   = type;
			this.source = source;
		}

		public InputControl( InputType type, InputSource source, Keys keys ) : this( type, source )
		{
			this.keys = keys;
		}

		public InputControl( InputType type, InputSource source, GamePadInput gamePad ) : this( type, source )
		{
			this.gamePad = gamePad;
		}

		public InputControl( InputType type, InputSource source, MouseInput mouse ) : this( type, source )
		{
			this.mouse = mouse;
		}

		#endregion

		#region Methods

		public override bool Equals( object obj )
		{
			InputControl input = obj as InputControl;
			if( input != null )
			{
				return this == input;
			}

			return false;
		}

		#endregion

		#region Properties

		public InputType Type
		{
			get
			{
				return this.type;
			}
		}

		public InputSource Source
		{
			get
			{
				return this.source;
			}
		}

		public Keys Keys
		{
			get
			{
				return this.keys;
			}
		}

		public GamePadInput GamePad
		{
			get
			{
				return this.gamePad;
			}
		}

		public MouseInput Mouse
		{
			get
			{
				return this.mouse;
			}
		}

		#endregion

		#region Operators

		public static bool operator ==( InputControl left, InputControl right )
		{
			return ( left.GamePad == right.GamePad && left.Keys == right.Keys &&
				     left.Mouse == right.Mouse && left.Source == right.Source &&
				     left.Type == right.Type );
		}

		public static bool operator !=( InputControl left, InputControl right )
		{
			return ( left.GamePad != right.GamePad || left.Keys != right.Keys ||
					 left.Mouse != right.Mouse || left.Source != right.Source ||
					 left.Type != right.Type );
		}

		#endregion
	}
}
